using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using DTO;

namespace DAO
{
  public class ThetvDAO
    {
        public static bool themthe(ThetvDTO sdto)
        {
            string sql = "insert into The(MaDG,Ngaycap,Ngayhethan)values('" + sdto.MaDG + "','" + sdto.Ngaycap + "','" + sdto.Ngayhethan + "')";
            return DataProvider.ExecuteNonQuery(sql);
        }
        public static int laymathe()
        {
            string sql = "select max(MaThe) from The";

            OleDbCommand cmd = new OleDbCommand(sql, DataProvider.ketnoi());
            int maphieu = (int)cmd.ExecuteScalar();
            int maphieumoi = maphieu + 1;
            return maphieumoi;


        }
        public static bool updatethe(ThetvDTO dto)
        {
            string sql = "update The set MaDG='" + dto.MaDG + "',Ngaycap=#" + dto.Ngaycap + "#,Ngayhethan='" + dto.Ngayhethan + "' where MaThe=" + dto.MaThe + " ";
            return DataProvider.ExecuteNonQuery(sql);
        }
        public static bool xoathe(ThetvDTO dto)
        {
            string sql = "delete from The where MaThe=" + dto.MaThe + "";
            return DataProvider.ExecuteNonQuery(sql);
        }
    }
}
